<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@page import="java.util.Date"%>
<%@page import="java.util.List"%>
<%@page import="feedme.dao.*"%>
<%@page import="feedme.bean.*"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.web.jsf.el.WebApplicationContextFacesELResolver"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="utils.*"%>

<%
String title = "选择食品";

String fsId = SuperString.notNullTrim(request.getParameter("fsId"));

WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
DaoFactory daoFactory = ctx.getBean("mongoDaoFactory", DaoFactory.class);

FoodDao fDao = daoFactory.getFoodDaoInstance();
List<?> foodList = fDao.findAll();

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=title%></title>
</head>
<body>
    <form action="order_moddo.jsp?act=add&type=food" method="post">
        <div>
        <select name="fId">
        <% for(int i = 0 ; i < foodList.size() ; i++) { %>
            <% FoodBean record = (FoodBean)foodList.get(i);  %>
            <option value="<%= record.getObjId() %>" >
                <%= record.getName() %> 
            </option> 
        <% } %>
        </select>
        </div>
        <div>
            <input type="submit" name="submit" value="我吃这个吧" />
        </div>
    </form>
    <p>上面没有你要吃的？</p>
    <form action="food_moddo.jsp?act=add&fsId=<%=fsId%>" method="post">
        <div>
            <input type="text" name="name" value="" />
            <input type="text" name="price" value="" />
        </div>
    </form>
</body>
</html>
